using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeUI.SmartParts;
using Jbe.TestSuite.Infrastructure.Shell.Properties;

namespace Jbe.TestSuite.Infrastructure.Shell
{
    [SmartPart]
    public partial class AboutForm : Form, IAboutView
    {
        private AboutViewPresenter presenter;

        [CreateNew]
        public AboutViewPresenter Presenter
        {
            set
            {
                presenter = value;
                presenter.View = this;
                netVersionText.Text = presenter.NetFrameworkVersion;
                copyrightText.Text = presenter.Copyright;
            }
        }

        public Button AcceptCancelButton 
        {
            get { return okButton; }
        }

        public AboutForm()
        {
            InitializeComponent();
            Text = String.Format(Resources.AboutProductName, Application.ProductName);

            productNameText.Text = Application.ProductName;
            productVersionText.Text = Application.ProductVersion;
            companyText.Text = Application.CompanyName;
        }

        public void AddModule(string name, string version)
        {
            ListViewItem item = moduleList.Items.Add(name);
            item.SubItems.Add(version);
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            presenter.OnViewReady();
        }

        private void CopyInfoButtonClick(object sender, EventArgs e)
        {
            presenter.CopyInfo();
        }

        private void SystemInfoButtonClick(object sender, EventArgs e)
        {
            presenter.SystemInfo();
        }

        private void OKButtonClick(object sender, EventArgs e)
        {
            presenter.Close();
        }
    }
}